const express = require('express')
const path = require('path');

const app = express()
app.use(express.static(path.join(__dirname, 'public')));
// 指定模板的位置
app.set('views', path.join(path.join(__dirname, 'views')));
// 设置模板引擎的格式为ejs
app.set('view engine', 'ejs');

const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.get('/ejs', (req, res) => {
  let obj = {
    title: '惊雷',
    name: 'MC井宁',
    content: 'hello world',
    time: [
      'yesterday',
      'today',
      'tomorrow'
    ],
    msg: 'ejs嵌套传值'
  }
  res.render('index', obj);
})

app.listen(port, () => console.log(`Example app listening on port ${port}!`))